package com.bub.pay.framework.common.base;

import java.util.Arrays;

/**
 * 项目模块编码
 */
public enum Module {
    admin(100, "admin"),
    agent(200, "agent"),
    merchant(300, "merchant"),
    job(400,"job"),
    mq_consumer(500,"mqConsumer"),
    open_service(600, "openService"),
    outer_net_server(700,"outerNetServer"),
    ;
    private Integer sn;
    private String desc;

    /**
     * 根据模块描述找到指定模块
     *
     * @param name name
     * @return 模块
     */
    public static Module which(String name) {
        return Arrays.stream(Module.values()).filter(m -> m.desc.equals(name)).findFirst().get();
    }

    /**
     * 根据模块返回系统中文名称
     *
     * @param module name
     * @return 模块
     */
    public static String getName(Module module) {
        switch (module.getSn()){
            case 100 :
                return "总管理平台";
            case 200:
                return "代理平台";
            case 300:
                return "合作商户平台";
            case 800:
                return "BUB客户端";
            default:
                return "";
        }
    }

    Module(Integer sn, String desc) {
        this.sn = sn;
        this.desc = desc;
    }

    public Integer getSn() {
        return sn;
    }

    public String getDesc() {
        return desc;
    }
}
